home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 November: Tool Chest / Dev.CD Nov 96 TC / Dev.CD Nov 96 TC.toast / Tool Chest / Development Tools & Languages / • Other Platforms / PCCTS 1.31 / Documentation / UPDAT131.txt < prev   
Encoding:
Text File  |  1995-03-10  |  8.5 KB  |  315 lines  |  [TEXT/MPS ]

  1.  
  2.                          PCCTS 1.31 Release Notes
  3.  
  4.                     Active Authors for 1.31 Release:
  5.  
  6.                               Terence Parr
  7.                         Parr Research Corporation
  8.                             5517 Pleasant Ave
  9.                           Minneapolis, MN 55419
  10.                               parrt@acm.org
  11.  
  12.                            Russell W. Quong
  13.                    School of Electrical Engineering
  14.                            Purdue University
  15.                         W. Lafayette, IN 47907
  16.                          quong@ecn.purdue.edu
  17.  
  18.                             Other authors:
  19.  
  20.                   Will Cohen, cohenw@ecn.purdue.edu
  21.                   Hank Dietz, hankd@ecn.purdue.edu
  22.  
  23.                            January 1, 1995
  24.  
  25.  
  26.     This document describes the 1.31 release of the Purdue Compiler
  27.     Construction Tool Set (PCCTS).  This file describes the changes
  28.     made to PCCTS 1.30 to arrive at PCCTS 1.31.  No major new
  29.     features were added, but lots of bug fixes were made.  The
  30.     original 1.00 manual and all release notes are required for a
  31.     complete documentation set for PCCTS.  A book is in the works and
  32.     the papers provided at the ftp site don't hurt.
  33.  
  34.     PCCTS is in the public-domain and can be obtained at
  35.     everest.ee.umn.edu in pub/pccts/1.31.  The newsgroup
  36.     comp.compilers.tools.pccts provides a discussion forum.  To
  37.     receive future release broadcast messages, register yourself by
  38.     sending email to pccts@ecn.purdue.edu with a ``Subject:'' line of
  39.     ``register''.  The WWW site is ``http://tempest.ecn.purdue.edu:8001/''
  40.  
  41.     The authors make no claims that this software will do what you
  42.     want, that this manual is any good, or that the software actually
  43.     works---use PCCTS at your own risk.  Bug reports and/or cheery
  44.     reports of its usefulness are very welcome, however.
  45.  
  46.     The maintenance and support of all PCCTS tools is primarily
  47.     provided by Parr Research Corporation, Minneapolis MN.  Please see
  48.     file PCCTS.FUTURE for more information.  All PCCTS tools currently
  49.     in the public domain will continue to be in the public domain.
  50.  
  51.  
  52.  
  53. I. NEW FEATURE
  54.  
  55. [Exception handling is still considered ALPHA quality--meaning that
  56.  things could change in the future.]
  57.  
  58. [Yes, we know that the '@' char is a hideous choice of operator
  59. symbols, but we had no other free symbols--TJP]
  60.  
  61. As a result of Terence's trip to NeXT in November, the parser
  62. exception handling has been proven a useful mechanism.  Our
  63. preliminary results indicate that error reporting is good and error
  64. recovery is as good or better than a hand-built parser.  However, the
  65. mechanism, as defined in the 1.30 release notes, was a bit unwieldy
  66. for the more common errors.  For example, given the grammar
  67.  
  68. start : A B ;
  69.  
  70. the programmer could generate exceptions to handle the cases where 'A'
  71. or 'B' were missing:
  72.  
  73. start : A B ;
  74.         exception
  75.             catch MismatchedToken : <</* error: missing token */>>
  76.  
  77. However, this approach would require that a similar exception be
  78. written for each alternative in the grammar that required missing
  79. tokens to be trapped LOCALLY--that is, handled immediately without
  80. throwing an exception to the calling rule.
  81.  
  82.                               BASIC IDEA
  83.  
  84. The programmer may suffix any token reference with the '@' operator;
  85. this indicates that if that token is not seen on the input stream,
  86. errors are to be handled immediately.  In particular, [for the moment]
  87. the function zzmatch_wdfltsig() or zzsetmatch_wdfltsig() is called in
  88. C and C++ mode.  We anticipate making these routines call the
  89. default/global handler specified by the user; i.e.,
  90.  
  91. <<
  92. main() {...}
  93. >>
  94. exception
  95.     catch MismatchedToken : <<my default handler>> // FUTURE!!!
  96.  
  97. a : ... ;
  98.  
  99. rather than having the user redefine these functions if necessary.
  100. The behavior of these routines upon an error is to print out an error
  101. message:
  102.  
  103. line 1: syntax error at "blah" missing BLECH
  104.  
  105. and then consumes input until a token is found that can possibly
  106. follow that token reference.  For example,
  107.  
  108. a : A@ stat ;
  109. stat : B | C ;
  110.  
  111. If 'A' is missing on the input stream, an error message would be
  112. printed and the parser would consume tokens until either a 'B' or a
  113. 'C' was seen.
  114.  
  115.                                SHORTHAND
  116.  
  117. The user may suffix the rule definition:
  118.  
  119. a@ : ... ;
  120.  
  121. or the '|' in an alternative definition:
  122.  
  123. a  :@ ...
  124.    |@ ...
  125.    ;
  126.  
  127. as a shorthand for placing an '@' after each token reference.
  128.  
  129.                        MORE FUNCTIONALITY INFO
  130.  
  131. Let's look at the functionality of the following grammar fragment:
  132.  
  133. stat    :    "if" expr "then"@ stat { "else"@ stat }
  134.     |@    u:ID "=" expr ";"
  135.     ;
  136.     exception
  137.         catch NoViableAlt : <</* bad or missing stat */>>
  138.  
  139. The behavior is summarized in the following table:
  140.  
  141. INPUT       ACTION EXECUTED
  142. ;           /* bad or missing stat */
  143. =           /* bad or missing stat */
  144. if 1 a=b;   match_wdfltsig(THEN) catches the missing 'then'; prints msg
  145.             and recovers by consuming until it finds an 'if' or an ID.
  146. a 3;        match_wdfltsig("=") catches the missing '='; prints msg
  147.             and recovers by consuming until it finds the first symbol
  148.             of a valid expr.
  149.  
  150.                             REAL EXAMPLE
  151.  
  152. Given input
  153.  
  154.     a = b;
  155.     B
  156.  
  157. this example will print
  158.  
  159.     line 1: syntax error at "a" missing BEGIN
  160.     found assignment to a
  161.  
  162. Given input
  163.  
  164.     a b;
  165.     B
  166.  
  167. the output will be
  168.  
  169.     line 2: syntax error at "b" missing =
  170.     found assignment to a
  171.  
  172. Given input
  173.  
  174.     A
  175.     if a+ then a=b;
  176.  
  177. the output will be
  178.  
  179.     invalid conditional in 'if' statement
  180.     found assignment to a
  181.  
  182. Given input
  183.  
  184.     A =
  185.  
  186. the output will be
  187.  
  188.     uncaught exception
  189.  
  190. ----------------
  191. #header <<#include "charbuf.h">>
  192.  
  193. <<
  194. main()
  195. {
  196.     int signal;
  197.     ANTLR(rule(&signal), stdin);
  198.     if ( signal ) fprintf(stderr, "uncaught exception\n");
  199. }
  200. >>
  201.  
  202. #token "[\ \t]+"    <<zzskip();>>
  203. #token "\n"         <<zzskip(); zzline++;>>
  204. #token THEN "then"
  205. #tokclass DIE    { "@" "if" ID "else" }
  206. #tokclass BEGIN { "A" "B" }
  207.  
  208. rule:   BEGIN@
  209.         ( stat )+
  210.         "end"@
  211.     ;
  212.  
  213. stat:   "if" t:expr "then"@ stat { "else"@ stat }
  214.     |@  u:ID "=" expr ";"
  215.         <<printf("found assignment to %s\n", $u.text);>>
  216.     ;
  217.     exception[t]
  218.         default :
  219.             <<
  220.             printf("invalid conditional in 'if' statement\n");
  221.             zzconsumeUntilToken(THEN);
  222.             >>
  223.  
  224. expr:   expr1 ("\+" expr1)*
  225.     ;
  226.  
  227. expr1
  228.     :   expr2 ("\*" expr2)*
  229.     ;
  230.  
  231. expr2:  ID
  232.     ;
  233.  
  234. #token ID "[a-z]+"
  235. ----------------
  236.  
  237.  
  238. II. CHANGES AND BUG FIXES
  239.  
  240. o    genmk was changed to use .o (see config.h) rather than .$(OBJEXT);
  241.     the result is a much cleaner makefile.
  242.  
  243. o    Added a 'typedef int TokenType;' in antlr.h (not that I change
  244.     all the 'int's everywhere in the output <wink>).
  245.  
  246. o    Fixed bug in testcpp/7 for ANTLR (didn't compute result correctly).
  247.  
  248. o    Added the '@' operator for exception handling
  249.  
  250. o    Fixed a few code gen bugs relating to exception handling: extra commas
  251.     and extra default clauses, etc...
  252.  
  253. o    Fixed demand lookahead in C++.  Kudos to Grant M. Gibson
  254.     gibson@sunquest.sunquest.com.
  255.  
  256. o    Fixed erroneous warnings concerning labels that were defined correctly.
  257.  
  258. o    ANTLR now allows "#ifndef" gates in #tokdef files
  259.  
  260. o    The prototype for zzdflthandler was wrong (had only one arg).
  261.  
  262. o    ANTLR forgot to ignore #if as a preprocessor symbol.  It thought it
  263.     was a tree label reference.  E.g.,
  264.  
  265.         #if defined(MAIN)
  266.  
  267.         got transformed into:
  268.  
  269.         if_ast defined(MAIN)
  270.  
  271. o    The wildcard mechanism was seriously hosed (ANTLR core-dumped).
  272.  
  273. o    DLG was closing a file more than once in main.c
  274.  
  275. o    Created NOTES.watcom for WATCOM 32bit C because its different than
  276.     other PC compilers.
  277.  
  278. o    The file dlgauto.h still had a __STDC__ instead of __USE_PROTOS guard.
  279.  
  280. o    Fixed a few bugs in preorder() and destroy() in ASTBase.C
  281.  
  282. o    I moved the definition of zzEOF_TOKEN (for C mode) into tokens.h
  283.     rather than having it defined in every file.
  284.  
  285. o    A bitset in the ANTLR output called 'WildCard_set' is available
  286.     (representing all valid token types) if '.' wildcard operator used
  287.     anywhere.
  288.  
  289. o    The syn() is now virtual in C++ mode so you can redefine it more
  290.     easily.
  291.  
  292.  
  293. III. A FEW KNOWN BUGS
  294.  
  295. o    I would like to make an auto test script for the C++ samples to
  296.     check their input/output.
  297.  
  298. o    FOLLOW(rule) and FIRST(rule) capabilities need to be added to the
  299.     tokclass declaration.
  300.  
  301. o    No warning is given for nonstandard signals used in parser exception
  302.     handling.
  303.  
  304. o    Nothing has been done about the failure of semantic predicates
  305.     with regards to exception handling.
  306.  
  307. o    No warning is given if all alts of a block are guesses: (...)?.
  308.  
  309.  
  310. IV. ACKNOWLEDGEMENTS
  311.  
  312. The usual culprits: all those who have been hammering away on ANTLR.
  313. We thank NeXT (Sumana Srinivasan and Mike Monegan) again for helping
  314. to shape the exception handling '@' operator.
  315.